﻿<!DOCTYPE html>
<html lang="en">

<head>
    <title>CDUT - Shopping Cart</title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" href="assets/images/logocdut.png">
    <link href="https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i&display=swap"
        rel="stylesheet">
    <link rel="stylesheet" href="http://cdn.bootstrapmb.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="assets/css/font-awesome.min.css">
    <link rel="stylesheet" href="assets/css/owl.carousel.min.css">
    <link rel="stylesheet" href="assets/css/animate.min.css">
    <link rel="stylesheet" href="assets/css/jquery-ui.css">
    <link rel="stylesheet" href="assets/css/slick.css">
    <link rel="stylesheet" href="assets/css/chosen.min.css">
    <link rel="stylesheet" href="assets/css/pe-icon-7-stroke.css">
    <link rel="stylesheet" href="assets/css/magnific-popup.min.css">
    <link rel="stylesheet" href="assets/css/lightbox.min.css">
    <link rel="stylesheet" href="assets/js/fancybox/source/jquery.fancybox.css">
    <link rel="stylesheet" href="assets/css/jquery.scrollbar.min.css">
    <link rel="stylesheet" href="assets/css/mobile-menu.css">
    <link rel="stylesheet" href="assets/fonts/flaticon/flaticon.css">
    <link rel="stylesheet" href="assets/css/style.css">
</head>

<body class="inblog-page" style="background-color: #FBAB7E;
    background-image: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%);">
    <header class="header style7">
        <div class="top-bar">
            <div class="container">
                <div class="top-bar-left">
                    <div class="header-message">
                        欢迎
                    </div>
                </div>
                <div class="top-bar-right">

                    <ul class="header-user-links" th:if="${session.loginUser==null}">
                        <li>
                            <a th:href="@{/login}">登录/注册 </a>
                        </li>
                    </ul>
                    <ul class="header-user-links" th:if="${session.loginUser!=null}">

                        <li>
                            <a style="color: #01c6fb">用户: </a>
                            <a th:text="${session.loginUser.username}" style="color: yellowgreen"> </a>
                            <a style="color: #01c6fb"> 您好！</a>
                            <a th:href="@{/user/logout}" th:text="' 注销'" style="color: orangered"></a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="container">
            <div class="main-header">
                <div class="row">
                    <div class="col-lg-3 col-sm-4 col-md-3 col-xs-7 col-ts-12 header-element"
                        style="left: 120px;padding-bottom: 0px;bottom: 35px;">
                        <div class="logo">
                            <a href="index.html">
                                <img width="50%" src="assets/images/logocdut.png" alt="img"
                                    style="width:40%;magin-top: 5px;">
                            </a>
                        </div>
                    </div>
                    <div class="col-lg-7 col-sm-8 col-md-6 col-xs-5 col-ts-12">
                        <div class="block-search-block">
                            <form class="form-search form-search-width-category">
                                <div class="form-content">
                                    <div class="category">
                                    </div>
                                    <div class="inner">
                                        <input type="text" class="input" name="s" value="" placeholder="搜索你感兴趣的商品"
                                            id="searchvalue">
                                    </div>
                                    <button class="btn-search" type="button" id="search">
                                        <span class="icon-search"></span>
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="header-nav-container">
            <div class="container">
                <div class="header-nav-wapper main-menu-wapper">
                    <div class="vertical-wapper block-nav-categori">
                        <div class="block-title">
                            <span class="icon-bar">
                                <span></span>
                                <span></span>
                                <span></span>
                            </span>
                            <span class="text">主页目录</span>
                        </div>
                        <div class="block-content verticalmenu-content">

                        </div>
                    </div>
                    <div class="header-nav">
                        <div class="container-wapper">
                            <ul class="CDUT-clone-mobile-menu CDUT-nav main-menu " id="menu-main-menu">
                                <li>
                                    <a th:href="@{/home}" title="Home">主页</a>
                                </li>
                                <li>
                                    <a th:href="@{/gridproducts_bannerslider}" class="CDUT-menu-item-title"
                                        title="Shop">铺子</a>
                                </li>

                                <li class="menu-item">
                                    <a th:href="@{/about}" class="CDUT-menu-item-title" title="About">关于我们</a>
                                </li>
                                <li class="menu-item">
                                    <a th:href="@{/shoppingcart}" class="CDUT-menu-item-title" title="add">发布</a>
                                </li>
                                <li class="menu-item" th:if="${session.loginUser!=null}">
                                    <a th:href="'gridproducts_bannerslider_my?uid='+${session.loginUser.uid}"
                                        class="CDUT-menu-item-title" title="add">我的</a>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </header>
    <div class="header-device-mobile">
        <div class="wapper">
            <div class="item mobile-logo">
                <div class="logo">
                    <a href="#">
                        <img width="50%" src="assets/images/logocdut.jpg" alt="img" style="width:40%;magin-top: 5px;">
                    </a>
                </div>
            </div>
            <div class="item item mobile-search-box has-sub">
                <a href="#">
                    <span class="icon">
                        <i class="fa fa-search" aria-hidden="true"></i>
                    </span>
                </a>
                <div class="block-sub">
                    <a href="#" class="close">
                        <i class="fa fa-times" aria-hidden="true"></i>
                    </a>
                    <div class="header-searchform-box">
                        <form class="header-searchform">
                            <div class="searchform-wrap">
                                <input type="text" class="search-input" placeholder="Enter keywords to search...">
                                <input type="submit" class="submit button" value="Search">
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="item menu-bar">
                <a class=" mobile-navigation  menu-toggle" href="#">
                    <span></span>
                    <span></span>
                    <span></span>
                </a>
            </div>
        </div>
    </div>
    <div class="site-content">
        <main class="site-main  main-container no-sidebar" style="background-color: #FFDFBC;">
            <div class="container">
                <div class="breadcrumb-trail breadcrumbs">
                    <ul class="trail-items breadcrumb" style="background-color: #FFDFBC;">
                        <li class="trail-item trail-begin">
                            <a href="">
                                <span>
                                    主页
                                </span>
                            </a>
                        </li>
                        <li class="trail-item trail-end active">
                            <span>
                                发布
                            </span>
                        </li>
                    </ul>
                </div>
                <div class="row">
                    <div class="main-content-cart main-content col-sm-12">
                        <h3 class="custom_blog_title">
                            发布我的
                        </h3>
                        <div class="page-main-content">
                            <div class="shoppingcart-content">
                                <!--                                        这里是信息提交表单-->
                                <p class="form-row form-row-wide">
                                    <label class="text">物品名称</label>
                                    <input type="text" class="input-text" id="gname1" placeholder="输入名称">
                                </p>
                                <p class="form-row form-row-wide">
                                    <label class="text">物品描述</label>
                                    <input type="text" class="input-text" id="des1" placeholder="输入商品描述(30字以内)">
                                </p>
                                <p class="form-row form-row-wide">
                                    <label class="text">物品价格</label>
                                    <input type="text" class="input-text" id="money1" placeholder="输入价格">
                                </p>
                                <p class="form-row form-row-wide">
                                    <label class="text">物品图片</label>
                                    <input type="file" class="btn-link" id="image1">
                                </p>
                                <p class="form-row form-row-wide">
                                    <button class="button" value="发布" id="goodadd1">发布</button>
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </main>
    </div>
    <script src="assets/js/jquery-1.12.4.min.js"></script>
    <script src="assets/js/jquery.plugin-countdown.min.js"></script>
    <script src="assets/js/jquery-countdown.min.js"></script>
    <script src="http://cdn.bootstrapmb.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="assets/js/owl.carousel.min.js"></script>
    <script src="assets/js/magnific-popup.min.js"></script>
    <script src="assets/js/isotope.min.js"></script>
    <script src="assets/js/jquery.scrollbar.min.js"></script>
    <script src="assets/js/jquery-ui.min.js"></script>
    <script src="assets/js/mobile-menu.js"></script>
    <script src="assets/js/chosen.min.js"></script>
    <script src="assets/js/slick.js"></script>
    <script src="assets/js/jquery.elevateZoom.min.js"></script>
    <script src="assets/js/jquery.actual.min.js"></script>
    <script src="assets/js/fancybox/source/jquery.fancybox.js"></script>
    <script src="assets/js/lightbox.min.js"></script>
    <script src="assets/js/owl.thumbs.min.js"></script>
    <script src="assets/js/jquery.scrollbar.min.js"></script>
    <script src='http://ditu.google.cn/maps/api/js?key=AIzaSyC3nDHy1dARR-Pa_2jjPCjvsOR4bcILYsM'></script>
    <script src="assets/js/frontend-plugin.js"></script>
    <script type="text/javascript">
        var btn1 = document.getElementById("goodadd1");
        btn1.onclick = function () {
            var formdata = new FormData();
            var gname = document.getElementById('gname1').value;
            var money = document.getElementById('money1').value;
            var des = document.getElementById('des1').value;
            if (des.length > 30) {
                alert("描述的长度过长,请修改!");
                return;
            }
            var uid = '[[${session.loginUser.uid}]]'
            formdata.append("file", document.getElementById('image1').files[0]);
            var xhr = new XMLHttpRequest();
            var str = "gname=" + gname + "&money=" + money + "&des=" + des + '&uid=' + uid;
            xhr.open("POST", "/good/addgood?" + str, true);
            xhr.send(formdata);
            xhr.onload = function () {
                var text = xhr.responseText;
                console.log(text);
                if (text == 1) {
                    alert("发布成功");
                    location.reload();
                } else {
                    alert("发布失败");
                    location.reload();
                }
            }
        }
    </script>
    <script type="text/javascript">
        var searchbtn = document.getElementById("search");
        searchbtn.onclick = function () {
            name = document.getElementById("searchvalue").value;
            if (name == "") {
                alert("请填写要搜索的商品名称");
                return;
            }
            var xhr = new XMLHttpRequest();
            var params = "name=" + name;
            xhr.open("GET", "/good/querygoodbyname2?" + params, true);
            xhr.send();
            xhr.onload = function () {
                document.write(xhr.responseText);
            }
        }
    </script>
</body>

</html>